<x-layout>


  <!---->
  <div class="m-wrap g-ld invite-box">
    <div class="m-box">

      <div class="m-c wow fadeInUp ">

        <div class="dest-a">
          <div class="f-box f-line">
            <div class="item t_l pl10">出块时间</div>
            <div class="item t_r pr10" id='d-1'></div>
          </div>
          <div class="f-box f-line">
            <div class="item t_l pl10">全网算力</div>
            <div class="item t_r pr10" id='d-2'></div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">收益/算力</div>
            <div class="item t_r pr10" id='d-3'></div>
          </div>
        </div>

        <div class="dest-a" style="margin-top: 25px;">
          <div class="f-box f-line">
            <div class="item t_l pl10">待领取收益</div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">MGCC</div>
            <div class="item t_r pr10" id='d-4'></div>
          </div>
        </div>
        <!-- 全网实时数据 -->
        <div class="dest-a" style="margin-top: 25px;">
          <div class="f-box f-line">
            <div class="item t_l pl10">全网实时数据</div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">静态算力</div>
            <div class="item t_r pr10" id='d-5'></div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">链接算力</div>
            <div class="item t_r pr10" id='d-6'></div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">小区算力</div>
            <div class="item t_r pr10" id='d-7'></div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">节点人数</div>
            <div class="item t_r pr10" id='d-8'></div>
          </div>
          <div class="f-box">
            <div class="item t_l pl10">超级节点</div>
            <div class="item t_r pr10" id='d-9'></div>
          </div>
        </div>

        <div class="dest-op">
          <button>销毁挖矿</button>
          <button type="button" id="tb-btn">提币</button>
        </div>

      </div>
    </div>
  </div>


  <!-- Modal -->
  <div class="modal fade" id="tipModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered ">
      <div class="modal-content mgcc-tc">
        <div class="modal-header mgcc-tc-title1">
          <div class="mgcc-tc-title-h5"></div>
          <button type="button" class="btn-close mgcc-tc-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">

          <div class="mgcc-tc-input-tips" style="text-align: center;font-size:18px">
            每次提取需要扣除5trx
          </div>
        </div>
        <div class="modal-footer mgcc-tc-footer">
          <button type="button" class="btn mgcc-tc-btn mgcc-tc-btn-1" id="confirmActiveTip">确定</button>
          <button type="button" class="btn mgcc-tc-btn mgcc-tc-btn-2" id="cancelActiveTip" data-bs-dismiss="modal">取消</button>
        </div>
      </div>
    </div>
  </div>

  <!-- Modal -->
  <div class="modal fade" id="tbModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered ">
      <div class="modal-content mgcc-tc">
        <div class="modal-header mgcc-tc-title2">
          <div class="mgcc-tc-title-h5"></div>
          <button type="button" class="btn-close mgcc-tc-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <input type="text" class="mgcc-tc-input" id="tb" placeholder="请输入提币数量">
          <div class="mgcc-tc-input-tips" id="tb_msg" style="display: none;">
            请输入邀请地址以激活你的账户
          </div>
        </div>
        <div class="modal-footer mgcc-tc-footer">
          <button type="button" class="btn mgcc-tc-btn mgcc-tc-btn-1" id="confirmActive">确定</button>
          <button type="button" class="btn mgcc-tc-btn mgcc-tc-btn-2" id="cancelActive" data-bs-dismiss="modal">取消</button>
        </div>
      </div>
    </div>
  </div>


</x-layout>
<!--partner-->

<!-- Swiper JS -->
<script>
  //初始化激活弹窗
  var tbmodal = document.getElementById('tbModal')
  var myTbmodal = new bootstrap.Modal(tbmodal, {
    keyboard: false
  })
  //初始化激活弹窗
  var tipmodal = document.getElementById('tipModal')
  var myTipmodal = new bootstrap.Modal(tipmodal, {
    keyboard: false
  })



  function eDate() {
    var h = moment().get("hour");
    var hours = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
    var eh = -1;
    var e = ''
    for (x in hours) {
      if (hours[x] == h) {
        eh = h + 2;
      } else {
        if (eh == -1) {
          eh = h + 1
        }
      }
    }

    if (eh == 24) {
      e = moment().add(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss');
    } else {
      e = moment().hours(eh).startOf('hour').format('YYYY/MM/DD HH:mm:ss');
    }
    return e;
  }


  //js部分
  function countTime(value) {
    //获取当前时间
    var date = new Date();
    var now = date.getTime();

    // alert(now)

    //设置截止时间
    //移动端必须这样写，因为ios不支持日期中间是-链接，会报错
    var endDate = new Date(eDate());
    var end = endDate.getTime();
    //时间差
    var differTime = end - now;
    //定义变量,h,m,s保存倒计时的时间
    var h, m, s;
    if (differTime >= 0) {
      h = Math.floor(differTime / 1000 / 60 / 60);
      m = Math.floor(differTime / 1000 / 60 % 60);
      s = Math.floor(differTime / 1000 % 60);
      h = h < 10 ? ("0" + h) : h;
      m = m < 10 ? ("0" + m) : m;
      s = s < 10 ? ("0" + s) : s;
      var timeDom = "" + h + ":" + m + ":" + s;
      $("#d-1").text(timeDom);
      //递归调用函数所以是延时器不是定时器
      setTimeout(function() {
        countTime(value)
      }, 1000);
    } else {
      var timeDom = "00:00:00";
      $("#d-1").text(timeDom);
    }
  }
  $(function() {

    token = mgToken()

    //获取邀请信息
    axios.post(mgRoute.info, {}, {
      headers: {
        token: token
      }
    }).then((r) => {
      var d = r.data
      if (d.status == 200) {
        j = d.data

        $("#d-2").text(j.totalComputingPower + 'T');
        $("#d-3").text(j.myIncome + 'T');
        $("#d-4").text(j.balance);
        $("#d-5").text(j.staticComputingPower + 'T');
        $("#d-6").text(j.linkComputingPower + 'T');
        $("#d-7").text(j.minPerformance + 'T');
        $("#d-8").text(j.nodeCount);
        $("#d-9").text(j.sNodeCount);


      } else {
        // alert("请求失败")
      }
    }).catch((e) => {
      dlog(e)
    })

    //倒计时
    countTime()


    $("#tb-btn").on("click", function() {
      myTipmodal.show();
    })

    $("#confirmActiveTip").on("click", function() {
      myTipmodal.hide();
      $("#tb").val('');
      myTbmodal.show();
    })


    //点击确定
    $("#confirmActive").on("click", function() {
      var v = $("#tb").val();
      var msg = $("#tb_msg");
      if (!v) {
        msg.show()
        return false;
      } else {
        msg.hide()
      }

      v = parseFloat(v)

      var token = mgToken();

      axios.post(mgRoute.withdraw, {
        "number": v
      }, {
        headers: {
          token: token
        }
      }).then((r) => {
        var resp = r.data
        if (resp.statu != 200) {
          alert(resp.data);
          return false;
        }
        alert('提币请求已提交')
      }).catch((e) => {
        dlog(e)
      })

    });

    //取消 关闭弹窗
    $("#cancelActive").on("click", function() {
      myTbmodal.hide()
    });

  })
</script>
